package com.nibian.nibian.app;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.util.Log;


/**
 * @创建者 luck
 * @创建时间 ${DATA} 10:32
 * @描述 ${application}
 * @更新者 $Author$
 * @更新时间 $Date$
 * @更新描述 ${TODO}
 */
public class MyApplication extends Application {
    private static Context sContext;        // 上下文
    private static  Handler sHandler;        // sHandler
    private static  int     sMainThreadId;       // 主线程 iconId
    private static  Thread   sMainthread;      // 主线程

    public static Context getContext() {
        return sContext;
    }

    public static Handler getHanlder() {
        return sHandler;
    }

    public static int getMainThreadId() {
        return sMainThreadId;
    }

    public static Thread getMainThread() {
        return sMainthread;
    }

    /**
     * app 一启动就会调用此方法, 因此在此初始化全局变量
     *此类在主线程中运行
     */
    @Override
    public void onCreate() {
        super.onCreate();
        sContext = this;
        Log.d("tag","MyApplication"+"全局");
        sContext = getApplicationContext();
        sHandler = new Handler();
        sMainThreadId = android.os.Process.myTid();             // 主线程 iconId
        sMainthread = Thread.currentThread();                   // 获取当前线程

//        Connector.getDatabase();
    }
}
